package com.xwd.dao.impl;

import com.xwd.dao.BaseDao;
import com.xwd.dao.EmpDao;
import com.xwd.pojo.Emp;

import java.util.List;

/*
 * @ClassName EmpDaoImpl
 * @Description: com.com.xwd.dao.impl
 * @Auther: xiwd
 * @Date: 2022/2/7 - 02 - 07 - 19:01
 * @version: 1.0
 */
public class EmpDaoImpl extends BaseDao implements EmpDao {
    //methods
    @Override
    public List<Emp> findAll() {
        String query_sql="\tSELECT emp.empno,ename,mgr,job,hiredate,sal,comm,deptno,grade\n" +
                "\tFROM emp,\t(SELECT empno,\n" +
                "\t\t\t\t\t\t\t(CASE\n" +
                "\t\t\t\t\t\t\t\tWHEN (sal+comm)>10000.0 THEN 'A'\n" +
                "\t\t\t\t\t\t\t\tWHEN (sal+comm)>8000.0 AND (sal+comm)<10000.0 THEN 'B'\n" +
                "\t\t\t\t\t\t\t\tELSE 'C' \n" +
                "\t\t\t\t\t\t\t\tEND)\n" +
                "\t\t\t\t\t\t\tas grade\n" +
                "\t\t\t\t\t\t\tFROM emp ) as A\n" +
                "\tWHERE emp.empno=A.empno";
        return (List<Emp>)(baseQuery(Emp.class, query_sql));
    }
}

